using MicroMsg.Common.Utils;
using MicroMsg.Scene;
using MicroMsg.Storage;
using System;
using System.Collections.Generic;
using System.Xml.Linq;
namespace MicroMsg.Manager
{
	public class BatchGetContactProfileMgr
	{
		private const string TAG = "BatchGetContactProfileMgr";
		public static bool batchGetProfile(List<string> userNameList)
		{
			Log.smethod_4("BatchGetContactProfileMgr", "batchGetProfile, in");
			List<string> list = new List<string>();
			using (List<string>.Enumerator enumerator = userNameList.GetEnumerator())
			{
				while (enumerator.MoveNext())
				{
					string current = enumerator.get_Current();
					if (!string.IsNullOrEmpty(current))
					{
						if (ContactMgr.getUserType(current) == ContactMgr.UserType.UserTypeQQ)
						{
							Contact contact = StorageMgr.contact.method_0(current);
							if (contact == null)
							{
								list.Add(current);
								continue;
							}
							if (contact.nImgUpdateSeq == 0 || contact.nExtInfoSeq == 0 || string.IsNullOrEmpty(contact.strExtInfo))
							{
								list.Add(current);
								continue;
							}
							continue;
						}
					}
					Log.smethod_1("BatchGetContactProfileMgr", "invalid userName = " + current);
				}
			}
			if (list.get_Count() == 0)
			{
				Log.smethod_5("BatchGetContactProfileMgr", "no user need get from server");
				return true;
			}
			return ServiceCenter.sceneBatchGetContactProfile.doScene(list);
		}
		public static bool getExtInfo(string xmlStr, ref ContactExtInfo info)
		{
			if (string.IsNullOrEmpty(xmlStr))
			{
				Log.smethod_5("BatchGetContactProfileMgr", "getExtInfo, input invalid para");
				return false;
			}
			bool result;
			try
			{
				XDocument xDocument = XDocument.Parse(xmlStr);
				XElement xElement = xDocument.Element("extinfo");
				XElement xElement2 = xElement.Element("age");
				if (xElement2 != null)
				{
					info.int_0 = int.Parse(xElement2.get_Value());
				}
				xElement2 = xElement.Element("sex");
				if (xElement2 != null)
				{
					info.int_1 = int.Parse(xElement2.get_Value());
				}
				xElement2 = xElement.Element("bd");
				if (xElement2 != null)
				{
					info.birthday = xElement2.get_Value();
				}
				xElement2 = xElement.Element("country");
				if (xElement2 != null)
				{
					info.country = xElement2.get_Value();
				}
				xElement2 = xElement.Element("province");
				if (xElement2 != null)
				{
					info.province = xElement2.get_Value();
				}
				xElement2 = xElement.Element("city");
				if (xElement2 != null)
				{
					info.city = xElement2.get_Value();
				}
				return true;
			}
			catch (Exception ex)
			{
				Log.smethod_1("BatchGetContactProfileMgr", ex.get_Message());
				result = false;
			}
			return result;
		}
	}
}
